package com.example.service;

import org.apache.activemq.command.ActiveMQTextMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

import javax.jms.Message;

@Service
public class MessageService {

    Logger logger = LoggerFactory.getLogger(getClass());

    @JmsListener(destination = "xxx")
    public void onMessage(Message message) throws Exception {
        if (message instanceof ActiveMQTextMessage) {
            logger.warn("客户端收到消息： " + ((ActiveMQTextMessage) message).getText());
        }

    }
}
